package com.onlineMIS.ORM.entity.headQ.supplier.purchase;


import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;

import com.onlineMIS.ORM.entity.headQ.barcodeGentor.Color;
import com.onlineMIS.ORM.entity.headQ.barcodeGentor.Product;
import com.onlineMIS.ORM.entity.headQ.inventory.InventoryOrderVO;
import com.onlineMIS.common.ExcelTemplate;


public class SupplierOrdersTemplate extends ExcelTemplate{
	public final static String FILE_NAME = "HeadqQSupplierPurchaseOrderTemplate.xls";
	private final int title_row = 0;
	private final int header_row1_ind = 2;
	
	
	private List<PurchaseOrderVO> list = new ArrayList<PurchaseOrderVO>();

	
	public SupplierOrdersTemplate(List<PurchaseOrderVO> list, String templateWorkbookPath) throws IOException{
		super(templateWorkbookPath);		
		this.list = list;	
	}
	public List<PurchaseOrderVO> getList() {
		return list;
	}
	public void setList(List<PurchaseOrderVO> list) {
		this.list = list;
	}


	public HSSFWorkbook process() {
		HSSFSheet sheet = templateWorkbook.getSheetAt(0);
		int totalDataRow = list.size();
		for (int i = 0; i < totalDataRow; i++){
			PurchaseOrderVO item = list.get(i);
			Row row = sheet.createRow(header_row1_ind + i);
			row.createCell(0).setCellValue(item.getId());
			row.createCell(1).setCellValue(item.getSupplier());
			if (item.getCreationTime() !=null) {
				row.createCell(2).setCellValue(item.getCreationTime());
			}
			if (item.getLastUpdateTime() !=null) {
				row.createCell(3).setCellValue(item.getLastUpdateTime());
			}			
			row.createCell(4).setCellValue(item.getStoreName());
			row.createCell(5).setCellValue(item.getOrderAuditor());
			row.createCell(6).setCellValue(item.getTotalQuantity());
			row.createCell(7).setCellValue(item.getTotalRecCost());
			row.createCell(8).setCellValue(item.getTotalWholePrice());
			row.createCell(9).setCellValue(item.getComment());
			row.createCell(10).setCellValue(item.getTypeS());
			row.createCell(11).setCellValue(item.getStatusS());

		}
		return templateWorkbook;
	}

}
